/*
 * @Author: your name
 * @Date: 2021-01-12 09:04:05
 * @LastEditTime: 2021-01-18 21:32:32
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \heima-mobileCP\src\utils\timeFormat.js
 */

import dayjs from 'dayjs'
// 加载 中文 语言包
import 'dayjs/locale/zh-cn'
// 引入相对时间处理模块
import rTime from 'dayjs/plugin/relativeTime'
dayjs.locale('zh-cn')
dayjs.extend(rTime)

// 处理固定时间格式
export const formatTime = (val, type) => {
  return dayjs(val).format(type)
}

// 处理相对时间格式
export const relativeTime = time => {
  return dayjs().to(dayjs(time))
}
